package com.zlk.algorithm.algorithm.greedy;

import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * @program: algorithm
 * @ClassName IPO
 * @description:输入正数数组costs、正数数组profits、正数K和正数M
 * costs[i]表示i号项目的花费 profits[i]表示i号项目在扣除花费之后还能挣到的钱(利润)
 * K表示你只能串行的最多做k个项目 M表示你初始的资金
 * 说明：每做完一个项目，马上获得的收益，可以支持你去做下一个项目，不能并行的做项目。
 * 输出：最后获得的最大钱数
 * @author: slfang
 * @create: 2024-02-27 15:22
 * @Version 1.0
 **/
public class IPO {

    public  int findMaximizedCapital(int K, int W, int[] Profits, int[] Costs) {
        PriorityQueue<Program> costQueue = new PriorityQueue<>((a,b)->a.c-b.c);
        PriorityQueue<Program> profitsQueue = new PriorityQueue<>((a,b)->b.p-a.p);
        for (int i = 0; i < Costs.length; i++) {
            costQueue.add(new Program(Profits[i],Costs[i]));
        }
        while (!costQueue.isEmpty()){
            Program poll = costQueue.poll();
            if(poll.c<W){
                profitsQueue.add(poll);
            }
        }
//        while (){
//
//        }
        return -1;

    }

    public  class Program {
        public int p;
        public int c;

        public Program(int p, int c) {
            this.p = p;
            this.c = c;
        }
    }

    public static class MinCostComparator implements Comparator<Program> {

        @Override
        public int compare(Program o1, Program o2) {
            return o1.c - o2.c;
        }

    }

    public static class MaxProfitComparator implements Comparator<Program> {

        @Override
        public int compare(Program o1, Program o2) {
            return o2.p - o1.p;
        }

    }


}
